package Thread;

public class Demo41 {
    private static int total=0;
    public static void main(String[] args) throws InterruptedException {
        //直接使用Runnable 实现上述1+...100
        Runnable runnable=new Runnable() {
            @Override
            public void run() {
                int sum=0;
                for (int i = 1; i <=100 ; i++) {
                    sum+=i;
                }
                total+=sum;
            }
        };
        Thread t=new Thread(runnable);
        t.start();
        t.join();
        System.out.println(total);
    }
}
